package blocos;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JOptionPane;

public class BlockLuminosityGUI extends BlockGUI{

	private String  onPath = "luminosity.jpg";
	private String  offPath = "luminosity.jpg";
	protected Image imgOnBig;
	protected Image imgOnMedium;
	protected Image imgOnSmall;
	protected Image imgOffBig;
	protected Image imgOffMedium;
	protected Image imgOffSmall;
	int fontSize = 64;
	private Font fontBig = new Font("Monospaced",Font.PLAIN,16);
	private Font fontMedium = new Font("Monospaced",Font.PLAIN,12);
	private Font fontSmall = new Font("Monospaced",Font.PLAIN,8);
	private Font font;
	
	public void paintComponent(Graphics g){	
		
		if(((BlockSensor)this.block).value.compareTo("0") == 0)
		{
			imgBig = imgOffBig;
			imgMedium = imgOffMedium;
			imgSmall = imgOffSmall;
		}
		else
		{
			imgBig = imgOnBig;
			imgMedium = imgOnMedium;
			imgSmall = imgOnSmall;
			
		}
		
		super.paintComponent(g);
		if(scale == 1) font = fontBig;
		else if (scale == 0.75) font = fontMedium;
		else font = fontSmall;
		g.setFont(font);
		g.setColor(Color.black);
        g.drawString(((BlockSensor)this.block).value,x+(int)(width*0.88),y+(int)(height*0.9));
		
	}
	
	public BlockLuminosityGUI(){
		
		super(); 
		
       	try {
       		imgOnBig = ImageIO.read(new File(defaultImagePathBig + onPath));
       		imgOnMedium = ImageIO.read(new File(defaultImagePathMedium + onPath));
       		imgOnSmall = ImageIO.read(new File(defaultImagePathSmall + onPath));
       		
       		imgOffBig = ImageIO.read(new File(defaultImagePathBig + offPath));
       		imgOffMedium = ImageIO.read(new File(defaultImagePathMedium + offPath));
       		imgOffSmall = ImageIO.read(new File(defaultImagePathSmall + offPath));
       		
	     }
	    catch(IOException e)
	    {
	    	JOptionPane.showMessageDialog(null, "Imagem nao encontrada", "Erro", JOptionPane.ERROR_MESSAGE);
	    }
		block = new BlockLuminosity("0");
	}
	@Override
	public String[] save() {
		// TODO Auto-generated method stub
		return null;
	}
}
